﻿#include "oeasyproxy.h"
#ifndef NO_WIDGETS
#include "ui_oeasyproxy.h"
#endif
#include "HCNetSDK.h"
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include "logfile.h"
#include "configfile.h"
#include "commonfuc.h"
#include "httpclient.h"


#define Oeasy_Versions "2.2.0"
static int s_ipcCount = 0;

bool g_Is_gameOver = false;
void CALLBACK fExceptionCB(DWORD dwType, LONG lUserID, LONG lHandle, void *pUser)
{
    if(g_Is_gameOver)
    {
        return;
    }

    DEBUG_PRINT << "";
    QList<IPC*> *p = (QList<IPC *> *)pUser;
    IPC *ipc = Q_NULLPTR;   
    QString log;
    foreach (IPC *tmp, *p)
    {
        if (tmp != Q_NULLPTR && tmp->m_lUserID == lUserID)
        {
            ipc = tmp;
            break;
        }
    }

    if (ipc == Q_NULLPTR)
    {
        log.clear();
        log.sprintf("not find ipc: lUserID = %d, lHandle = %d, dwType = 0x%x", (int)lUserID, (int)lHandle, (int)dwType);
        logFile::printLog(log);
    }
    else//在ipc中找到
    {
        log.clear();
        log.sprintf("find ipc match: ip = %s, lHandle = %d, dwType = 0x%x", ipc->m_ipcInfo.ip.toStdString().c_str(), (int)lHandle, (int)dwType);
        logFile::printLog(log);
        switch (dwType)
        {
        case EXCEPTION_EXCHANGE:
            break;
        case EXCEPTION_RECONNECT:
            ipc->m_devState = false;
            break;
        case EXCEPTION_ALARMRECONNECT:
            break;
        case PREVIEW_RECONNECTSUCCESS:
            ipc->m_devState = true;
            break;
        case ALARM_RECONNECTSUCCESS:
            break;
        case RESUME_EXCHANGE:
            break;
        default:
            log.clear();
            log.sprintf("default: dwType = 0x%x",(int)dwType);
            logFile::printLog(log);
            break;
        }
    }
}

void CALLBACK MessageCallback(LONG lCommand, NET_DVR_ALARMER *pAlarmer, char *pAlarmInfo, DWORD dwBufLen, void *pUser)
{
    if(g_Is_gameOver)
    {
        return;
    }

    QString log;
    switch (lCommand)
    {
    case COMM_ALARM_V30:
    {
        QList<IPC*> *p = (QList<IPC *> *)pUser;

        NET_DVR_ALARMINFO_V30 struAlarmInfo;
        memcpy(&struAlarmInfo, pAlarmInfo, dwBufLen);

        switch (struAlarmInfo.dwAlarmType)
        {
        case 3: //移动侦测报警
            foreach (IPC *ipc, *p)
            {
                if (ipc != Q_NULLPTR && ipc->m_lUserID == pAlarmer->lUserID)
                {
                    emit ipc->motionAlarm();
                }
            }
            break;
        default:
            log.clear();
            log.sprintf("missing: device ip: %s ,dwAlarmType = %d",pAlarmer->sDeviceIP, (int)struAlarmInfo.dwAlarmType);
            logFile::printLog(log);
            break;
        }
    }
        break;
    default:
//        log = "missing lCommand";
//        logFile::printLog(log);
        break;
    }
}

#ifndef NO_WIDGETS
OeasyProxy::OeasyProxy(QWidget *parent) :
    QMainWindow(parent),
#else
OeasyProxy::OeasyProxy(QObject *parent) :
    QObject(parent),
#endif
    m_ipcList(),
    /*m_picServer(g_ConfigFile.m_cfg.general.faceJpgRecvPort, g_ConfigFile.m_cfg.general.proxyId, g_ConfigFile.m_cfg.face),*/
    m_access(m_ipcList, g_ConfigFile.m_cfg.general.proxyUrl, g_ConfigFile.m_cfg.general.proxyId, g_ConfigFile.m_cfg.face.enterUrl),
    m_timer()
{
#ifndef NO_WIDGETS
    ui = new Ui::OeasyProxy;
    ui->setupUi(this);
#endif

	g_ConfigFile.SetConfig(g_ConfigFile.m_cfg); //用于生成默认配置文件      
	QString log;
    log.sprintf("**************Program startup**********\n");
    logFile::printLog(log);

    log.sprintf("####versions:%s####\n",Oeasy_Versions);
    logFile::printLog(log);

    if(!g_ConfigFile.isValid()){
        log.clear();
        log.sprintf("OeasyKey is not Valid, Sorry!");
        logFile::printLog(log);
        exit(0);
        return;
    }
    initSigalHanle();
    createRecordFolder();

    m_intercom = Q_NULLPTR;
    m_intercomProxy = Q_NULLPTR;
    //nOpenDataSourceMode --- >0：可视对讲；1：代理连接(通过边界系统推送过来的数据)
    int nOpenDataSourceMode = g_ConfigFile.m_cfg.general.nOpenDataSourceMode;
    if(0 == nOpenDataSourceMode)
    {
        m_intercom = new Intercom(g_ConfigFile.m_cfg.general.intercomPort);
        m_intercom->listen();
    }
    else
    {
        m_intercomProxy = new IntercomProxy(g_ConfigFile.m_cfg.general.intercomPort);
        m_intercomProxy->listen();
    }

    initIpc();
    m_pTargetCli = new TargetCli(g_ConfigFile.m_cfg.general.proxyId, g_ConfigFile.m_cfg.target, g_ConfigFile.m_cfg.general, m_ipcList);
    connect(m_pTargetCli, SIGNAL(postPic(QByteArray)), this, SLOT(onPostPic(QByteArray)));
    connect(m_pTargetCli, SIGNAL(postTmpPic(QByteArray)), this, SLOT(onPostTmpPic(QByteArray)));
    connect(m_pTargetCli, SIGNAL(postReport(QByteArray)), this, SLOT(onPostReport(QByteArray)));
    foreach (IPC *ipc, m_ipcList) {
        connect(ipc, SIGNAL(sendMsgToTargetCli(QByteArray)), m_pTargetCli, SLOT(OnSendToTargetCli(QByteArray)));
    }
    initLog();

    connect(&m_timer, SIGNAL(timeout()), this, SLOT(onTimeout()));

    if(0 == nOpenDataSourceMode)
    {
        connect(m_intercom, SIGNAL(sigOpenDoor(QByteArray)), this, SLOT(onOpenDoor(QByteArray)));
    }
    else
    {
        connect(m_intercomProxy, SIGNAL(sigOpenDoor(QByteArray)), this, SLOT(onOpenDoor(QByteArray)));
    }

    m_timer.start(g_ConfigFile.m_cfg.general.postTimeout);

    initUploadOpenDoorInfor();
}

OeasyProxy::~OeasyProxy()
{
    delete m_pTargetCli;
    foreach (IPC *ipc, m_ipcList)
    {
        if (ipc != Q_NULLPTR)
        {
            m_ipcList.removeOne(ipc);
            ipc->deleteLater();
            ipc = Q_NULLPTR;
        }
    }
    cleanupUploadOpenDoorInfor();

    QSettings *settings = new QSettings(OeasyKeyPath, QSettings::IniFormat);
    int facecount = settings->value("CurIPCCount", 0).toInt();
    if(facecount >= s_ipcCount)
    {
        int set = facecount - s_ipcCount ;
        settings->setValue("CurIPCCount", set >0 ? set:0);
        settings->sync();
    }
    delete settings;
    settings = Q_NULLPTR;

    // 释放SDK资源
    NET_DVR_Cleanup();

    QString log;
    log.sprintf("\n**************Program is over**************\n\n");
    logFile::printLog(log);

#ifndef NO_WIDGETS
    delete ui;
#endif

}

void OeasyProxy::createRecordFolder()
{
   QString strRoot = CommonFuc::getAppDirPath();
   QString strPath;
   strPath.append(strRoot);
   strPath.append("record");
   QDir nvrDir;
   if (!nvrDir.exists(strPath))
   {
       nvrDir.mkdir(strPath);
   }

   m_Group = "openDoor_Infor";
   m_strRecordDirPath = CommonFuc::getRecordPath();
   QString fileName = m_strRecordDirPath + "cache_infor.record";
   m_pRecord = new Settings(fileName,QSettings::IniFormat, this);
}

void sigHandle(int dunno)
{
#ifdef __linux
 /* 信号处理例程，其中dunno将会得到信号的值 */
    switch (dunno)
    {
        case SIGINT:
        case SIGQUIT:
        case SIGABRT:
        case SIGKILL:
        case SIGSEGV:
        {
            qDebug()<<"sigHandle get sigal: "<<dunno;
            QSettings *settings = new QSettings(OeasyKeyPath, QSettings::IniFormat);
            int facecount = settings->value("CurIPCCount", 0).toInt();
            qDebug()<<"facecount==: "<<facecount;
            if(facecount >= s_ipcCount)
            {
                settings->setValue("CurIPCCount", facecount - s_ipcCount);
                settings->sync();
            }
            delete settings;
            settings = Q_NULLPTR;
            s_ipcCount = 0;
        }
        break;
    }
    QString log;
    log.sprintf("sigHandle  get signal: %d\n", dunno);
    logFile::printLog(log);
    return;
#endif
}

void OeasyProxy::initSigalHanle()
{
#ifdef __linux
    s_ipcCount = 0;
    signal(SIGINT, sigHandle);
    signal(SIGQUIT, sigHandle);
    signal(SIGABRT, sigHandle);
    signal(SIGKILL, sigHandle);
    signal(SIGSEGV, sigHandle);
#endif
}

void OeasyProxy::initIpc()
{
    BOOL bRet;
    QString log;
    DEBUG_PRINT << "initIpc...";
    log.sprintf("initIpc...");
    logFile::printLog(log);

    //SDK初始化
    bRet = NET_DVR_Init();
    if (!bRet)
    {
        log.clear();
        log.sprintf("NET_DVR_Init error: %d", (int)NET_DVR_GetLastError());
        logFile::printLog(log);
        WARNING_PRINT << "NET_DVR_Init error:" << NET_DVR_GetLastError();
    }

    //注册异常消息回调函数
 #ifndef WIN32
 #define WM_NULL 0x0000  //sd copy from winuser.h
 #endif
    bRet = NET_DVR_SetExceptionCallBack_V30(WM_NULL, Q_NULLPTR, fExceptionCB, (void*)&m_ipcList);
    if (!bRet)
    {
        log.clear();
        log.sprintf("NET_DVR_SetExceptionCallBack_V30 error: %d", (int)NET_DVR_GetLastError());
        logFile::printLog(log);
        WARNING_PRINT << "NET_DVR_SetExceptionCallBack_V30 error:" << NET_DVR_GetLastError();
    }

    //设置报警回调函数
    bRet = NET_DVR_SetDVRMessageCallBack_V30(MessageCallback, (void*)&m_ipcList);
    if (!bRet)
    {
        log.clear();
        log.sprintf("NET_DVR_SetDVRMessageCallBack_V30 error: %d", (int)NET_DVR_GetLastError());
        logFile::printLog(log);
        WARNING_PRINT << "NET_DVR_SetDVRMessageCallBack_V30 error:" << NET_DVR_GetLastError();
    }
    int maxipcCount = g_ConfigFile.m_cfg.keyinfo.maxFaceChannel + g_ConfigFile.m_cfg.keyinfo.maxTargetChannel;
    for (int i = 0, j = ceil(sqrt(g_ConfigFile.m_cfg.ipcList.size())); i < g_ConfigFile.m_cfg.ipcList.size() && i < maxipcCount; i++)
    {
#ifndef NO_WIDGETS
        QWidget *widget = new QWidget(ui->tab_video);
        ui->gridLayout_video->addWidget(widget, i/j, i%j);
        m_ipcList.append(new IPC(g_ConfigFile.m_cfg.general.proxyId, QString("").sprintf("%04d", i), g_ConfigFile.m_cfg.ipcList[i], g_ConfigFile.m_cfg.face, g_ConfigFile.m_cfg.car, widget));
#else
        Q_UNUSED(j);
        m_ipcList.append(new IPC(g_ConfigFile.m_cfg.general.proxyId, QString("").sprintf("%04d", i), g_ConfigFile.m_cfg.ipcList[i], g_ConfigFile.m_cfg.face, g_ConfigFile.m_cfg.car));
#endif
        //nOpenDataSourceMode --- >0：可视对讲；1：代理连接(通过边界系统推送过来的数据)
        int nOpenDataSourceMode = g_ConfigFile.m_cfg.general.nOpenDataSourceMode;
        if(0 == nOpenDataSourceMode)
        {
           connect(m_ipcList.at(i), SIGNAL(faceSuccess(QString, QString, QByteArray)), m_intercom, SLOT(onFaceOpenDoor(QString, QString, QByteArray)));
        }
        connect(m_ipcList.at(i), SIGNAL(postPic(QByteArray)), this, SLOT(onPostPic(QByteArray)));
        connect(m_ipcList.at(i), SIGNAL(postTmpPic(QByteArray)), this, SLOT(onPostTmpPic(QByteArray)));
        connect(m_ipcList.at(i), SIGNAL(postReport(QByteArray)), this, SLOT(onPostReport(QByteArray)));
        connect(m_ipcList.at(i), SIGNAL(postBigData(QByteArray)), this, SLOT(onPostBigData(QByteArray)));
        s_ipcCount++;
    }
    if(s_ipcCount < g_ConfigFile.m_cfg.ipcList.size())
    {
        log.clear();
        log.sprintf("OeasyKey limit Access! IPC index %d and later will not valid!", s_ipcCount+1);
        logFile::printLog(log);
        WARNING_PRINT << "OeasyKey limit Access! IPC index:"<< s_ipcCount+1 <<"and later will not valid!";
    }
    QSettings *settings = new QSettings(OeasyKeyPath, QSettings::IniFormat);
    int curCount= settings->value("CurIPCCount", 0).toInt();
    int set = curCount - s_ipcCount ;
    settings->setValue("CurIPCCount", set >0 ? set:0);
    settings->sync();
    delete settings;
    settings = Q_NULLPTR;
}

void OeasyProxy::initLog()
{
#ifndef NO_WIDGETS
    QTextEdit *log_access = new QTextEdit(ui->tab_log);
    log_access->hide();
    ui->gridLayout_log->addWidget(log_access, 0, 0);
    connect(log_access, SIGNAL(textChanged()), this, SLOT(onLogChanged()));
    connect(&m_access, SIGNAL(textRecv(QString)), log_access, SLOT(append(QString)));
    connect(&m_access, SIGNAL(textRecv(QString)), log_access, SLOT(show()));

    QTextEdit *log_targetCli = new QTextEdit(ui->tab_log);
    log_targetCli->hide();
    ui->gridLayout_log->addWidget(log_targetCli, 0, 1);
    connect(log_targetCli, SIGNAL(textChanged()), this, SLOT(onLogChanged()));
    connect(m_pTargetCli, SIGNAL(textRecv(QString)), log_targetCli, SLOT(append(QString)));
    connect(m_pTargetCli, SIGNAL(textRecv(QString)), log_targetCli, SLOT(show()));

    QTextEdit *log_intercom = new QTextEdit(ui->tab_log);
    log_intercom->hide();
    ui->gridLayout_log->addWidget(log_intercom, 1, 0);
    connect(log_intercom, SIGNAL(textChanged()), this, SLOT(onLogChanged()));

    //nOpenDataSourceMode --- >0：可视对讲；1：代理连接(通过边界系统推送过来的数据)
    int nOpenDataSourceMode = g_ConfigFile.m_cfg.general.nOpenDataSourceMode;
    if(0 == nOpenDataSourceMode)
    {
        connect(m_intercom, SIGNAL(textRecv(QString)), log_intercom, SLOT(append(QString)));
        connect(m_intercom, SIGNAL(textRecv(QString)), log_intercom, SLOT(show()));
    }
    else
    {
        connect(m_intercomProxy, SIGNAL(textRecv(QString)), log_intercom, SLOT(append(QString)));
        connect(m_intercomProxy, SIGNAL(textRecv(QString)), log_intercom, SLOT(show()));
    }


    QTextEdit *log_picServer = new QTextEdit(ui->tab_log);
    log_picServer->hide();
    ui->gridLayout_log->addWidget(log_picServer, 1, 1);
    connect(log_picServer, SIGNAL(textChanged()), this, SLOT(onLogChanged()));
    //connect(&m_picServer, SIGNAL(textRecv(QString)), log_picServer, SLOT(append(QString)));
    //connect(&m_picServer, SIGNAL(textRecv(QString)), log_picServer, SLOT(show()));
#endif
}

void OeasyProxy::httpOperate(QNetworkRequest req, QNetworkAccessManager::Operation opera, const QPair<QByteArray, int> &data)
{
    QNetworkAccessManager *m = new QNetworkAccessManager();
    QNetworkReply *r = Q_NULLPTR;
    if (opera == QNetworkAccessManager::GetOperation)
    {
        r = m->get(req);
    }
    else if (opera == QNetworkAccessManager::PostOperation)
    {
        r = m->post(req, data.first);
    }

    if (r != Q_NULLPTR)
    {
        m_replyMap[r] = data;
        connect(m, SIGNAL(finished(QNetworkReply*)), this, SLOT(onPostFinish(QNetworkReply*)));
    }
    else
    {
        delete m;
    }
}

void OeasyProxy::onLogChanged()
{
#ifndef NO_WIDGETS
    QTextEdit *tmp = (QTextEdit*)this->sender();
    QString textContent = tmp->toPlainText();
    int len = textContent.count();
    int maxLen = 1024;
    if (len > maxLen)
    {
        textContent.remove(0, len - maxLen);
        tmp->setText(textContent);

        QTextCursor textCursor = tmp->textCursor();
        textCursor.movePosition(QTextCursor::End);
        tmp->setTextCursor(textCursor);
    }
#endif
}

void OeasyProxy::onPostTmpPic(const QByteArray &data)
{
    QNetworkRequest req(QUrl(g_ConfigFile.m_cfg.general.tmpPicUrl + "/upload"));

    req.setHeader(QNetworkRequest::ContentTypeHeader, "image/jpeg");
    httpOperate(req, QNetworkAccessManager::PostOperation, qMakePair(data, -1));
}

void OeasyProxy::onPostPic(const QByteArray &data)
{
    QNetworkRequest req(QUrl(g_ConfigFile.m_cfg.general.picUrl + "/upload"));

    req.setHeader(QNetworkRequest::ContentTypeHeader, "image/jpeg");
    httpOperate(req, QNetworkAccessManager::PostOperation, qMakePair(data, -1));
}

void OeasyProxy::onPostReport(const QByteArray &data)
{
    QNetworkRequest req(QUrl(g_ConfigFile.m_cfg.general.reportUrl));

    req.setHeader(QNetworkRequest::ContentTypeHeader, "json");
    httpOperate(req, QNetworkAccessManager::PostOperation, qMakePair(data, -1));
}

void OeasyProxy::onPostBigData(const QByteArray &data)
{
    QNetworkRequest req(QUrl(g_ConfigFile.m_cfg.general.bigDataUrl + "?msgJson=" + data));

    req.setHeader(QNetworkRequest::ContentTypeHeader, "json");
    httpOperate(req, QNetworkAccessManager::GetOperation, qMakePair(QByteArray(), -1));
}

void OeasyProxy::onPostFinish(QNetworkReply *r)
{
    if (r->error() != QNetworkReply::NoError)
    {
        WARNING_PRINT << r->url() << r->error();
    }
    m_replyMap.remove(r);
    r->manager()->deleteLater();
}

void OeasyProxy::onTimeout()
{
    QList<QNetworkReply *> keys = m_replyMap.keys();
    foreach (QNetworkReply *r, keys)
    {
        QPair<QByteArray, int> &data = m_replyMap[r];
        data.second++;
        if (data.second >= 1 && data.second <= g_ConfigFile.m_cfg.general.postFailNum)
        {
            httpOperate(r->request(), r->operation(), data);
            DEBUG_PRINT << r->url() << r->bytesToWrite() << data.second << data.first.size();
            m_replyMap.remove(r);
            r->manager()->deleteLater();
        }
        else if (data.second > g_ConfigFile.m_cfg.general.postFailNum + 1)
        {
            QFile file(QString("").sprintf("%p.jpg",r));
            if (!file.exists())
            {
                if (file.open(QIODevice::WriteOnly))
                {
                    file.write(data.first);
                    file.close();
                }
            }
            m_replyMap.remove(r);
            r->manager()->deleteLater();
        }
    }
}

void OeasyProxy::initUploadOpenDoorInfor()
{
    m_pManageThreadUploadInfor = new QThread;
    m_pUploadInforThread = new uploadOpenDoorInforThread;

    m_pUploadInforThread->moveToThread(m_pManageThreadUploadInfor);
    connect(this, SIGNAL(sigInitPara(TRANSFER_INFO)), m_pUploadInforThread, SLOT(onInitPara(TRANSFER_INFO)),Qt::QueuedConnection);

    m_pManageThreadUploadInfor->start();

    emit sigInitPara(g_ConfigFile.m_cfg.transferInfo);
}

void OeasyProxy::cleanupUploadOpenDoorInfor()
{
    if(m_pManageThreadUploadInfor)
    {
        m_pManageThreadUploadInfor->exit();
        m_pManageThreadUploadInfor->deleteLater();
        m_pManageThreadUploadInfor = Q_NULLPTR;
    }

    if(m_pUploadInforThread)
    {
        m_pUploadInforThread->deleteLater();
        m_pUploadInforThread = Q_NULLPTR;
    }

    if(m_pRecord)
    {
        delete m_pRecord;
        m_pRecord = Q_NULLPTR;
    }
}

void OeasyProxy::onOpenDoor(QByteArray data)
{
    DEBUG_PRINT << "open door information data:" << data;
    if(Q_NULLPTR == m_pRecord)
    {
        return;
    }

    QString strLog = QString("Write the open door infor ...");
    logFile::printLog(strLog);
    DEBUG_PRINT << strLog;

    QString strValue = data;
    QString strKey = QString();
    QDateTime dateTime = QDateTime::currentDateTime();
    strKey.append(dateTime.toString("yyyy-MM-dd_hh_mm_ss_zzz"));
    strKey.append(".opendoorinfor");

    m_pRecord->setValue(m_Group, strKey, strValue);
    strLog.sprintf("Add open door information Record:key=%s;value=%s.",strKey.toStdString().c_str(),strValue.toStdString().c_str());
    logFile::printLog(strLog);
    DEBUG_PRINT << strLog;

    return;
}

/*
void OeasyProxy::onOpenDoor(QByteArray data,QString mac,QString ipc_ic)
 {
    QString log;
    int i = 0;
    for(i=0;i<g_ConfigFile.m_cfg.ipcList.size();i++)
    {
        if(0==QString::compare(mac,g_ConfigFile.m_cfg.ipcList.at(i).intercomMac))
        {
            //ipc_ic可以为空，因为只有人脸才会传递IPC的IP
            if(!ipc_ic.isEmpty())
            {
                if(ipc_ic==g_ConfigFile.m_cfg.ipcList.at(i).ip)
                {
                    break;
                }
            }
            else
            {
                break;
            }
        }
    }

    //没找到
    if(i>=g_ConfigFile.m_cfg.ipcList.size())
    {
        log.clear();
        log.sprintf("not find mac in ipcList,mac=%s,ipc_ip=%s", mac.toStdString().c_str(),ipc_ic.toStdString().c_str());
        logFile::printLog(log);
        WARNING_PRINT << "not find mac in ipcList,mac=" <<mac;
        return;
    }

    //把CameraID添加到记录中传到后台
    IPC* pIpc = m_ipcList.at(i);
    if(Q_NULLPTR == pIpc)
    {
        return;
    }
    QString strCameraId = pIpc->GetCamerId();
    QJsonParseError jsonErr;
    QJsonObject jsonObj;
    QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonErr);
    if (jsonErr.error != QJsonParseError::NoError && !jsonDoc.isObject())
    {
        return ;
    }
    jsonObj = jsonDoc.object();
    jsonObj.insert("camera_id",strCameraId);
    jsonDoc.setObject(jsonObj);
    QByteArray newData = jsonDoc.toJson(QJsonDocument::Compact);

     if(g_ConfigFile.m_cfg.bUseNvr)//使用nvr
    {
        int nvrNo = g_ConfigFile.m_cfg.ipcList.at(i).parentNVR;
        if(nvrNo<m_nvrList.size()&&nvrNo>=0)
        {
            NVR *nvr=m_nvrList.at(nvrNo);
            emit nvr->sigSnapAndGetVideo(newData,g_ConfigFile.m_cfg.ipcList.at(i).NVRChannel,m_ipcList.at(i)->m_lRealPlayHandle);
        }
    }
    else//不使用nvr
    {
        if(i<m_ipcsnapList.size())
        {
            emit m_ipcsnapList.at(i)->sigSnapAndGetVideo(newData);
        }
    }
}*/

/*void OeasyProxy::closeEvent(QCloseEvent *event)
{
    Q_UNUSED(event);

    //nOpenDataSourceMode --- >0：可视对讲；1：代理连接(通过边界系统推送过来的数据)
    int nOpenDataSourceMode = m_cfg.m_cfg.general.nOpenDataSourceMode;
    if(0 == nOpenDataSourceMode)
    {
        if(m_intercom)
        {
            delete m_intercom;
            m_intercom = Q_NULLPTR;
        }
    }
    else
    {
        if(m_intercomProxy)
        {
            delete m_intercomProxy;
            m_intercomProxy = Q_NULLPTR;
        }
    }
}*/
